﻿@{Layout = "~/Views/Shared/_Layout.cshtml";}
@model IEnumerable<Scheduling.Models.Course>
<h1>Courses</h1>
<form method="post">
    <table>
        <tr>
            <td>Course: </td>
            <td><input type="text" name="inSearchCoursePattern" value="@ViewData["inSearchCoursePattern"]" /></td>
        </tr>
        <tr>
            <td colspan="2"><input type="submit" value="Search" /></td>
        </tr>
    </table>
</form>
<h2>Search Results</h2>
<p class="BodyText">For search query: <em>'@ViewData["inSearchCoursePattern"]'</em></p>
@if(Model.Count() > 0)
{
    <table class="Table" cellspacing="0">
        <tr>
            <th>Course ID</th>
            <th>Name</th>
            <th>HP</th>    
        </tr>
        @foreach (var course in Model) {
            <tr onclick="location.href='@Href("~/Course/Show/" + course.ID)'" class="Clickable">
                <td style="width:70px;">@course.ID</td>
                <td style="width:280px;">@course.Name</td>
                <td style="width:70px;">@course.Points</td>
                <td>@Html.ActionLink("View Bookings", "ListBookings", new { id = course.ID })</td>
            </tr>
        }
    </table>
}

else if (ViewData["inSearchCoursePattern"] == null && Model.Count() == 0)
{

    <p>Please enter a search query.</p>
}

else
{
    <p>No Search Results... </p>
}